package com.zhou.spring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhouyanxiang
 * @create 2020-07-2020/7/14-20:47
 */
@Controller
@RequestMapping("/user")
public class HelloWorld {

    @RequestMapping("/hello")
//    @ResponseBody
    /**
    * 如果是单纯的想引用返回界面，则需要在pom.xml中引入thymeleaf引擎模板
     * 然后返回的String就能索引到和他名字相同的html界面去
    */
    public String HelloWorld(ModelMap map){
        map.put("name","Tom");
        return "success";
    }

    @RequestMapping("/map")
    @ResponseBody
    public Map<String,String> map(){
        Map <String, String> map = new HashMap<>();
        map.put("zhangsan","23");
        map.put("lisi","24");
        map.put("wangwu","25");
        map.put("liu","77");
        return map;
    }
}
